package gamagora.box2d
{
	import Box2D.Collision.Shapes.b2Shape;
	import Box2D.Dynamics.b2Body;
	import Box2D.Dynamics.b2BodyDef;
	import Box2D.Dynamics.b2Fixture;
	import Box2D.Dynamics.b2FixtureDef;

	public class OSPhysicObject
	{
		private var _fixDef:b2FixtureDef;
		private var _bodyDef:b2BodyDef
		private var _fixture:b2Fixture;
		private var _body:b2Body;
		
		public function OSPhysicObject()
		{
			_fixDef = new b2FixtureDef();
			_bodyDef = new b2BodyDef();
		}
		
		public function create(x:Number, y:Number):void
		{
			x /= OSPhysicWorld.ratio;
			y /= OSPhysicWorld.ratio;
			
			_bodyDef.position.Set(x, y);
			
			_body = OSPhysicWorld.add(_bodyDef);
			_fixture = _body.CreateFixture(_fixDef);
		}
		
		public function getX():Number
		{
			return _body.GetPosition().x * OSPhysicWorld.ratio; 
		}
		
		public function getY():Number
		{
			return _body.GetPosition().y * OSPhysicWorld.ratio; 
		}
		
		public function getAngle():Number
		{
			return _body.GetAngle() * (180 / Math.PI);
		}
		
		//Getters Setters

		public function get body():b2Body
		{
			return _body;
		}

		public function get fixDef():b2FixtureDef
		{
			return _fixDef;
		}

		public function get bodyDef():b2BodyDef
		{
			return _bodyDef;
		}


		public function get fixture():b2Fixture
		{
			return _fixture;
		}

		public function set body(value:b2Body):void
		{
			_body = value;
		}

	}
}